
function intTochartDataJSON(powerInt){
    dataArray = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","-",".");
    
    var xxx = Math.floor(powerInt / 64);
    var yyy = powerInt % 64;
    
    var chartchar = dataArray[xxx]+dataArray[yyy];
    return chartchar;
}

function graphGetter() {
    $.getJSON("./hourlyhistory.json", function(json){
              var url ="<img src=\"http://chart.apis.google.com/chart?cht=bvs&chs=1000x300&chg=20,10,1,30&chd=e:"
              var xdim = "";
              for (var i = json.History.HOUR.length -1 ; i >= 0 ; i--) {
              var hourdata = json.History.HOUR[i];
              
              
              
              
              
              var date = hourdata.DATE.split(" ");
              var timevalue = date[1].split(":");
              var hourvalue = timevalue[0];
              xdim += hourvalue + "|";
              //１時間あたりのパワーを取得         
              var power= hourdata.POWER;
              //整数データに変換
              var powerInt = parseInt(power);
              
              //グラフのために微調整。ここは要改善
              powerInt = parseInt(powerInt*2.9);
              //e:の企画に合うように数字を文字列に変換
              var chartchar = intTochartDataJSON(powerInt);
              
              //プロット
              
              //if((i+1)< data.History.HOUR.length){
              if(i > 0 ){ 
              url += chartchar;
              }
              else{
              url += chartchar+",";
              } 
              
              
              }
              
              url+= "&chxt=x,y&chxl=0:|"+xdim+"1:|0|200|400|600|800|1000|1200|1400";
              //urlの最終情報補完
              var Today = "";
              var date = new Date();
              
              Today += "Date:"+(date.getMonth()+1)+"/"+date.getDate();
              url +="&chco=FFC266&chtt="+Today+"&chm=D,FF9900,0,0,3,1\"/>";
              
              $("#jsondata").append(url);                         
              
              });
}

